package com.lilong.jwt.controller.user;

import com.lilong.jwt.common.base.BaseService;
import com.lilong.jwt.common.base.CommonController;
import com.lilong.jwt.common.util.ResultBean;
import com.lilong.jwt.common.util.ResultUtil;
import com.lilong.jwt.entity.user.User;
import com.lilong.jwt.pojo.query.ListBean;
import com.lilong.jwt.service.user.UserService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/sys/user/")
public class UserController extends CommonController<User> {
    @Resource
    private UserService userService;

    @Override
    protected BaseService<User> getService() {
        return userService;
    }

    @DeleteMapping("delete")
    public ResultBean delete(@RequestBody ListBean<Long> listBean) {
        return ResultUtil.SUCCESS(userService.batchRemove(listBean.getData(), getOperator()));
    }

    @PutMapping("able")
    public ResultBean able(Long id) {
        return ResultUtil.SUCCESS(userService.able(id, getOperator()));
    }
    @GetMapping(value = "/info")
    public ResultBean getUserInfo(){
        System.out.println(getOperator());
        return ResultUtil.SUCCESS(getOperator());
    }
}
